function LifeBonus( width, height )
{
    this.image = document.getElementById( 'life' ); 
    this.speed = 2;        
    this.width = 35;
    this.height = 35;
    this.x = getRandomArbitary( 0, width - this.width );
    this.y = -this.height;
    this.life = 'false';            
    this.scale = 1; 
    this.angle = 0;                     
}

LifeBonus.prototype.draw = function( context )
{     
    context.save();
    
    context.translate( this.x - ( this.scale * this.width ) / 2, this.y - ( this.scale * this.height ) / 2 );
    context.scale( this.scale, this.scale );
    context.drawImage( this.image, 0, 0, this.width, this.height );

    context.restore();
}; 

function getLifeBonus( lifeBonus, width, height )
{                     
    if ( lifeBonus.life == 'false' )
    {
        var percent = getRandomArbitary( 1, 100 );
            
        if ( percent <= 100 )
        {
            lifeBonus = new LifeBonus( width, height );
            lifeBonus.life = 'true';
        }
    }
    else
    {
        lifeBonus.y += lifeBonus.speed;
        lifeBonus.scale = 1 + Math.sin( lifeBonus.angle ) * 0.2;
        lifeBonus.angle += 0.1;  
    }
    if ( lifeBonus.y > height )
    {
        lifeBonus.life = 'false';
    }
    return lifeBonus;
}               
